<template>
  <div>
    <h1>客户表</h1>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="id" width="350" height="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="用户名" width="350" height="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.username }}</span>
        </template>
      </el-table-column>
      <el-table-column label="头像" width="350" height="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px"><el-avatar :src="scope.row.cover" @click="getusername" :size="100"></el-avatar></span>
        </template>
      </el-table-column>
      <el-table-column label="订单书" width="350" height="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.books }}</span>
        </template>
      </el-table-column>
      <el-table-column label="角色" width="350" height="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.name }}</span>
        </template>
      </el-table-column>

      <el-table-column label="密码" width="350" height="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.password }}</span>
        </template>
      </el-table-column>

      <!-- <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column> -->
    </el-table>
  </div>
</template>
  <script>
export default {
  name: "orderpage",
  data() {
    return {
      tableData: [
        {
          id: "",
          username: "",
          books: "",
          name: "",
          cover: "",
          password: "",
        },
      ],
    };
  },
  methods: {
    loadCustomer() {
      this.$axios.get("/customer").then((resp) => {
        console.log(resp.data);
        //   this.tableData.length=resp.data.length
        // for (var i = 0; i < resp.data.length; i++){
        this.tableData = resp.data;

        // this.tableData[i].username = resp.data[i].username;
        // this.tableData[i].orderbooks = resp.data[i].title
        // this.tableData[i].role = resp.data[i].name
        // }
      });
    },
  },
  mounted: function () {
    this.loadCustomer();
  },
};
</script>
  <style scoped>
img {
  width: 115px;
  height: 172px;
  /*margin: 0 auto;*/
}
</style>